<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Sergi::Acts::Messageable::Mailbox</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Sergi::Acts::Messageable::Mailbox</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../../files/lib/mailbox_rb.html">
                lib/mailbox.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000044">&lt;&lt;</a>&nbsp;&nbsp;
      <a href="#M000047">[]</a>&nbsp;&nbsp;
      <a href="#M000039">add</a>&nbsp;&nbsp;
      <a href="#M000043">delete</a>&nbsp;&nbsp;
      <a href="#M000045">empty_trash</a>&nbsp;&nbsp;
      <a href="#M000046">has_conversation?</a>&nbsp;&nbsp;
      <a href="#M000038">latest_mail</a>&nbsp;&nbsp;
      <a href="#M000035">mail</a>&nbsp;&nbsp;
      <a href="#M000034">mail_count</a>&nbsp;&nbsp;
      <a href="#M000040">mark_as_read</a>&nbsp;&nbsp;
      <a href="#M000041">mark_as_unread</a>&nbsp;&nbsp;
      <a href="#M000042">move_to</a>&nbsp;&nbsp;
      <a href="#M000032">new</a>&nbsp;&nbsp;
      <a href="#M000037">read_mail</a>&nbsp;&nbsp;
      <a href="#M000033">type=</a>&nbsp;&nbsp;
      <a href="#M000036">unread_mail</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">type</td>
          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
          <td class="context-item-desc">
this is used to filter <a href="Mailbox.html#M000035">mail</a> by mailbox
type, use the [] method rather than setting this directly.

</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">user</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc">
the user/owner of this mailbox, set when initialized.

</td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000032.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000032.html');return false;">
          <span class="method-name">new</span><span class="method-args">(user, type = :all)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
creates a <a href="Mailbox.html#M000032">new</a> <a
href="Mailbox.html">Mailbox</a> instance with the given user and optional
type.
</p>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000044" class="method-detail">
        <a name="M000044"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000044.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000044.html');return false;">
          <span class="method-name">&lt;&lt;</span><span class="method-args">(msg)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
alias for <a href="Mailbox.html#M000039">add</a>
</p>
        </div>
      </div>

      <div id="method-M000047" class="method-detail">
        <a name="M000047"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000047.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000047.html');return false;">
          <span class="method-name">[]</span><span class="method-args">(mailbox_type)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
sets the mailbox type and returns itself.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">mailbox_type:</td><td>type of mailbox to filter <a href="Mailbox.html#M000035">mail</a> by, this
can be anything, but the three most likely values for this will be the
received, sent, and trash values set within the acts_as_messageable method.

</td></tr>
</table>
<h4>returns:</h4>
<p>
self
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #all mails in the user's inbox
   phil.mailbox[:inbox].mail
</pre>
        </div>
      </div>

      <div id="method-M000039" class="method-detail">
        <a name="M000039"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000039.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000039.html');return false;">
          <span class="method-name">add</span><span class="method-args">(msg)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
adds a <a href="Mailbox.html#M000035">mail</a> message to the user&#8216;s
mailbox specified by type.
</p>
<p>
*this is used when sending a <a href="Mailbox.html#M000032">new</a>
message, all the recipients get a <a href="Mailbox.html#M000035">mail</a>
added to their inbox and the sender gets a <a
href="Mailbox.html#M000035">mail</a> in their sentbox.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">msg:</td><td><a href="../../../Message.html">Message</a> object from which a <a
href="Mailbox.html#M000032">new</a> <a href="Mailbox.html#M000035">mail</a>
is created from.

</td></tr>
</table>
<h4>returns:</h4>
<p>
<a href="Mailbox.html#M000032">new</a> <a
href="../../../Mail.html">Mail</a>.
</p>
        </div>
      </div>

      <div id="method-M000043" class="method-detail">
        <a name="M000043"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000043.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000043.html');return false;">
          <span class="method-name">delete</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
permanantly deletes all the <a href="Mailbox.html#M000035">mail</a>
messages matched by the options. Use <a
href="Mailbox.html#M000042">move_to</a>(:trash) instead if you want to send
to user&#8216;s trash without deleting.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
        </div>
      </div>

      <div id="method-M000045" class="method-detail">
        <a name="M000045"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000045.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000045.html');return false;">
          <span class="method-name">empty_trash</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
deletes all messages that have been trashed and match the options if
passed.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
        </div>
      </div>

      <div id="method-M000046" class="method-detail">
        <a name="M000046"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000046.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000046.html');return false;">
          <span class="method-name">has_conversation?</span><span class="method-args">(conversation)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
return true if the user is involved in the given conversation.
</p>
        </div>
      </div>

      <div id="method-M000038" class="method-detail">
        <a name="M000038"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000038.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000038.html');return false;">
          <span class="method-name">latest_mail</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns an array of the latest <a href="../../../Mail.html">Mail</a>
message for each conversation the user is involved in filtered by type, if
set.
</p>
<p>
*possible use for this would be an inbox view of your <a
href="Mailbox.html#M000035">mail</a> so you can easily see the status of
all the convos your involved in.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
<h4>returns:</h4>
<p>
array of <a href="../../../Mail.html">Mail</a>.
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #get a list of the latest received mail for each conversation
   phil.mailbox[:inbox].latest_mail
</pre>
        </div>
      </div>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000035.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000035.html');return false;">
          <span class="method-name">mail</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns an array of all <a href="../../../Mail.html">Mail</a> for the user
filtered by type, if set.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>all valid find options are accepted as well as an additional conversation
option.

</td></tr>
</table>
<ul>
<li>:conversation - <a href="../../../Conversation.html">Conversation</a>
object to filter <a href="Mailbox.html#M000035">mail</a> only belonging to
this conversation.

</li>
<li>:conditions - same as find conditions however the array version of
conditions will not work, i.e., :conditions =&gt; [&#8216;mail.read =
?&#8217;, false] will not work here.

</li>
<li>all other find options will work as expected.

</li>
</ul>
<h4>returns:</h4>
<p>
array of <a href="../../../Mail.html">Mail</a>.
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #get all mail messages belonging to phil
   phil.mailbox.mail

   #get all mail messages in phil's inbox associated with conversation 23
   phil.mailbox[:inbox].mail(:conversation =&gt; Conversation.find(23))

   #get all unread mail messages belonging to phil associated with conversation 23
   phil.mailbox.mail(:conversation =&gt; Conversation.find(23), :conditions =&gt; 'mail.read = false')
</pre>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000034.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000034.html');return false;">
          <span class="method-name">mail_count</span><span class="method-args">(filter = :all, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns a count of <a href="Mailbox.html#M000035">mail</a> messages
filtered by type and filter, if set.
</p>
<p>
*this performs an actual sql count rather than selecting all <a
href="Mailbox.html#M000035">mail</a> and then gettin a length on the
array&#8230; not a big deal but this could be something that is checked
often to notify the user when they receive a <a
href="Mailbox.html#M000032">new</a> <a
href="Mailbox.html#M000035">mail</a>.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">filter:</td><td>filters the count by the &#8216;read&#8217; attribute.

</td></tr>
</table>
<ul>
<li>:all - count of both read and unread <a
href="Mailbox.html#M000035">mail</a>.

</li>
<li>:read - count of read <a href="Mailbox.html#M000035">mail</a>.

</li>
<li>:unread - count of unread <a href="Mailbox.html#M000035">mail</a>.

</li>
</ul>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
<h4>returns:</h4>
<p>
number of <a href="Mailbox.html#M000035">mail</a> messages
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #get number of unread mail messages in phil's inbox
   phil.mailbox[:inbox].mail_count(:unread)
</pre>
        </div>
      </div>

      <div id="method-M000040" class="method-detail">
        <a name="M000040"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000040.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000040.html');return false;">
          <span class="method-name">mark_as_read</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
marks all the <a href="Mailbox.html#M000035">mail</a> messages matched by
the options and type as read.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
<h4>returns:</h4>
<p>
array of <a href="../../../Mail.html">Mail</a>.
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #mark all inbox messages as read
   phil.mailbox[:inbox].mark_as_read()
</pre>
        </div>
      </div>

      <div id="method-M000041" class="method-detail">
        <a name="M000041"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000041.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000041.html');return false;">
          <span class="method-name">mark_as_unread</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
marks all the <a href="Mailbox.html#M000035">mail</a> messages matched by
the options and type as unread, except for sent messages.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
<h4>returns:</h4>
<p>
array of <a href="../../../Mail.html">Mail</a>.
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #mark all inbox messages as unread
   phil.mailbox[:inbox].mark_as_unread()
</pre>
        </div>
      </div>

      <div id="method-M000042" class="method-detail">
        <a name="M000042"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000042.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000042.html');return false;">
          <span class="method-name">move_to</span><span class="method-args">(mailbox, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
moves all <a href="Mailbox.html#M000035">mail</a> matched by the options to
the given mailbox. sent messages stay in the sentbox.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">mailbox:</td><td>the mailbox_type to move the <a href="Mailbox.html#M000035">mail</a>
messages to. (ex. :inbox, :trash)

</td></tr>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
        </div>
      </div>

      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000037.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000037.html');return false;">
          <span class="method-name">read_mail</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns an array of read <a href="../../../Mail.html">Mail</a> for the user
filtered by type, if set.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
<h4>returns:</h4>
<p>
array of <a href="../../../Mail.html">Mail</a>.
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #get all read mail in phil's inbox
   phil.mailbox[:inbox].read_mail
</pre>
        </div>
      </div>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000033.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000033.html');return false;">
          <span class="method-name">type=</span><span class="method-args">(val)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
sets the mailbox type to the symbol corresponding to the given val.
</p>
        </div>
      </div>

      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">
          <a href="Mailbox.src/M000036.html" target="Code" class="method-signature"
            onclick="popupCode('Mailbox.src/M000036.html');return false;">
          <span class="method-name">unread_mail</span><span class="method-args">(options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
returns an array of unread <a href="../../../Mail.html">Mail</a> for the
user filtered by type, if set.
</p>
<h4>params:</h4>
<table>
<tr><td valign="top">options:</td><td>see <a href="Mailbox.html#M000035">mail</a> for acceptable options.

</td></tr>
</table>
<h4>returns:</h4>
<p>
array of <a href="../../../Mail.html">Mail</a>.
</p>
<h4>example:</h4>
<pre>
   phil = User.find(3123)

   #get all unread mail in phil's inbox
   phil.mailbox[:inbox].unread_mail
</pre>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>